package com.zyh.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class RandomNumber {
    public static String productBsnSrNo(){
        //全局流水号  8位日期+6位时间+12位序列号
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String dateTime = sdf.format(date);
        StringBuffer stringBuffer = new StringBuffer();
        Random random = new Random();
        for(int i=0;i<12;i++){
            stringBuffer.append(random.nextInt(10));
        }
        return "302300"+dateTime+stringBuffer.toString();
    }


    public static String productRcvSrlNo(){
        //超网流水号  45+渠道（6位）+4位日期+7位序列号
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
        String dateTime = sdf.format(date);
        StringBuffer stringBuffer = new StringBuffer();
        Random random = new Random();
        for(int i=0;i<3;i++){
            stringBuffer.append(random.nextInt(10));
        }
        return "45"+"C40120"+dateTime+stringBuffer.toString();
    }

    public static String productTxnDt(){
        //交易日期
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String txnDt = sdf.format(date);
        return txnDt;
    }

    public static String productTxnTm(){
        //交易时间
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("HHmmss");
        String txnTm = sdf.format(date);
        return txnTm;
    }

}
